package Frame.sayoptional;

import FCRendering.FCRMaster;
import Frame.shopSet.*;
import VWorldGameStudio.FCEvent;
import VWorldGameStudio.events.ShopEvent;

import static FCRendering.FCRMaster.*;

public class OpenTypeOptional implements ISayoption {

    @Override
    public void clickWhichOption(SayTextAndOption op) {
        if (op.optionTextRepoId != null) {
            FCRMaster.fcv.setSayText(new String[]{op.optionTextRepoId});
        }
        if (op.getEventId() != null) {
            FCEvent qw = FCRMaster.eventLib.getEventOfName(op.getEventId());
            FCRMaster.fcv.setPlayingEvent(qw);
            System.out.println("OpenTypeOptional type:" + qw.getType());
            if (qw.getType().equals("shop")) {
                ShopEvent shopEvent = (ShopEvent) qw;
                if ("Taxi".equals(shopEvent.getType2())) {
                    fcv.setCurrentAShopFuntion(new FunctionTanZuCheShop());
                } else if ("RewardShop".equals(shopEvent.getType2())) {
                    fcv.setCurrentAShopFuntion(new FunctionWantedShop());
                } else if ("buyOutShop".equals(shopEvent.getType2())) {
                    fcv.setCurrentAShopFuntion(new FunctionBuyOutShop());
                } else if ("BAR".equals(shopEvent.getType2())) {
                    fcv.setCurrentAShopFuntion(new FunctionBarShop());
                } else {
                    fcv.setCurrentAShopFuntion(new FunctionCommonShop());
                }
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("repairService")) {
                fcv.setCurrentAShopFuntion(new FunctionRepairShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("fillService")) {
                fcv.setCurrentAShopFuntion(new FunctionBuManSop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("upgradeCdevice")) {
                fcv.setCurrentAShopFuntion(new FunctionUpgradeCDeviceShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("upgradeDiPan")) {
                fcv.setCurrentAShopFuntion(new FunctionUpgradeDipanShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("upgradeEngine")) {
                fcv.setCurrentAShopFuntion(new FunctionUpgradeEgShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("saveAndTake")) {
                fcv.setCurrentAShopFuntion(new FunctionSaveAndTakeShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("xiCheShop")) {
                fcv.setCurrentAShopFuntion(new FunctionXiCheShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("monsterTest")) {
                fcv.setCurrentAShopFuntion(new FunctionMonsterTest());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("retire")) {

            } else if (qw.getType().equals("commonMabiAnMo")) {
                fcv.setCurrentAShopFuntion(new FunctionAnMoShop());
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("touzi")) {
                fcv.setCurrentAShopFuntion(new FunctionTouZiShop(op.getParam()));
                fcv.setOpenSayShop(true);
            } else if (qw.getType().equals("itemCtrl")) {
                String eventName = qw.getName();
                if (eventName.equals("MaiJiBaiShuYes")) {
                    if (!gameSave.getFcEventHasHanppen().contains(eventName)) {
                        if(player1.addItemToKnapsack("jieZhi")) {
                            fcv.getMessage().add("发现女式的戒指！");
                            fcv.showMessage();
                            gameSave.getFcEventHasHanppen().add(eventName);
                        }else {
                            fcv.getMessage().add("发现闪光的东西，但是背包不足!");
                            fcv.showMessage();
                        }
                    }else {
                        fcv.getMessage().add("土地松动了");
                        fcv.showMessage();
                    }
                }else if (eventName.equals("createCompony")) {
                    if(gameSave.isCreateCompany()){
                        fcv.getMessage().add("你已经注册公司了无需重复注册.");
                        fcv.showMessage();
                    }else {
                        if(player1.getMoney() >= 100){
                            player1.setMoney(player1.getMoney() - 100);
                            fcv.getMessage().add("恭喜注册成立 "+player1.getChName()+"有限投资公司");
                            fcv.showMessage();
                            gameSave.setCreateCompany(true);
                        }else {
                            fcv.getMessage().add("抱歉余额不足.");
                            fcv.showMessage();
                        }
                    }
                }
            }
        }
    }
}
